package com.waiter.moximoxi.net;

import android.content.Context;
import android.provider.Settings;


import com.waiter.moximoxi.constant.Constant;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import cn.yhong.aframework.utils.SpUtils;

/**
 * 接口
 */
public final class API extends APIUtils {

    //测试服务器
    public static final String IP = "https://www.moshisushi.cn/api.php/";


    //登录
    public static final String login = IP + "index/login";
    //登出
    public static final String loginout = IP + "index/loginout";
    //获取分店
    public static final String getshop = IP + "index/getshop";
    //获取餐厅区域
    public static final String table_category = IP + "android/table_category";
    //获取根据餐厅区域获取对应区域内的餐桌
    public static final String table_list = IP + "android/table_list";
    //根据餐桌id获取其就餐账单明细
    public static final String order_goods = IP + "android/order_goods";
    //账单明细里面的确认送达手工操作按钮
    public static final String true_send = IP + "android/true_send";
    //请求结账
    public static final String request_finish_order = IP + "caipin/caipin_is_status";
    //确认呼叫
    public static final String true_call_waiter = IP + "android/true_call_waiter";
    //查询会员信息（扫码、输入手机号）
    public static final String get_user_info = IP + "android/get_user_info";
    //结算账单
    public static final String jiesuan = IP + "android/jiesuan";
    //安卓结算页，折扣展示
    public static final String jiesuan_discount = IP + "android/jiesuan_discount";
    //安卓结算页，点击使用折扣
    public static final String use_discount = IP + "android/use_discount";
    //安卓结算页，取消使用折扣
    public static final String cancel_discount = IP + "android/cancel_discount";
    //验证优惠券是否可用
    public static final String check_coupon = IP + "android/check_coupon";
    //取消优惠券
    public static final String cancel_coupon = IP + "android/cancel_coupon";
    //会员卡支付
    public static final String member_pay = IP + "android/member_pay";
    //河马支付
    public static final String pay_sand_code = IP + "android/pay_sand_code";
    //刷卡支付回调数据写入数据库
    public static final String pay_card_write = IP + "android/pay_card_write";
    //打印账单（小票）
    public static final String print_receipt = IP + "android/print_receipt";
    //人工抹零
    public static final String jiezhang_moling = IP + "android/jiezhang_moling";


    //河马付地址：
    //测试环境 交易测试地址
    public static final String hema_pay_ceshi = "https://star.sandgate.cn/gateway/api";
    //预发布环境 商户交易地址
    public static final String hema_pay_pre = "https://hmpay.sandpay.com.cn/gateway_test/api";
    //正式环境 商户交易地址
    public static final String hema_pay_formal = "https://hmpay.sandpay.com.cn/gateway/api";

//-----------------------------------------------------------------------------------------------------------------------------------------------------------

    /**
     * 获取请求头
     */
    public static Map<String, String> getHeads(Context context) {
        Map<String, String> headers = new LinkedHashMap<>();
        headers.put("MX-Token", (String) SpUtils.getData(context, Constant.USER_TOKEN, ""));
        headers.put("MX-device-type", "android");
        headers.put("MX-Admin-Type", "3");
        headers.put("MX-Shop-Id", (int) SpUtils.getData(context, Constant.LOGIN_STORE, 0) + "");
        return headers;
    }

    /**
     * 获取请求头
     */
    public static Map<String, String> getLoginHeads() {
        Map<String, String> headers = new LinkedHashMap<>();
        headers.put("MX-device-type", "android");
        return headers;
    }

    /**
     * 请求参数
     */
    public static Map<String, String> getParams() {
        Map<String, String> params = new HashMap<>();
        return params;
    }


    /**
     * 获取设备id
     *
     * @param context
     * @return
     */
    public static String getDeviceID(Context context) {
        if (context == null) {
            return "";
        }
        String android_id = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
        return android_id == null ? "" : android_id;
    }
}
